#ifndef CMYFUNC_H
#define CMYFUNC_H
#include "func.h"
#include <QtScript>

class CJSFunc: public CFunc
{
	QString m_str;
public:
	CJSFunc(const QString & str): m_str(str)
	{
	}
	virtual ~CJSFunc(){}
	virtual double operator () (double x)
	{
		QScriptEngine engine;
		engine.evaluate(m_str);
		QScriptValue f = engine.globalObject().property("f");
		QScriptValueList args;
		args << x;
		return f.call(QScriptValue(), args).toNumber();
	}
};

#endif // CMYFUNC_H
